package com.wenhai.leetcode.array;

/**
 * https://leetcode-cn.com/problems/merge-sorted-array/
 *
 * @author wenhai
 * @date   2021/3/30
 */
public class _88合并两个有序数组 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int i = m - 1;
        int j = n - 1;
        int k = nums1.length - 1;
        while (j >= 0) {
            if (i >= 0 && nums1[i] > nums2[j]) {
                nums1[k--] = nums1[i--];
            } else {
                nums1[k--] = nums2[j--];
            }
        }
    }
}
